package com.wxq.yaoxia.util;

public class YXConstants {
	public static String YX_USE = "use4";
	public static String YX_USE_DRUG = "use4drug";
	public static String YX_USE_DISEASE = "use4disease";
	
	public static final String DATABASE_PATH = "/data/data/com.wxq.yaoxia/databases/";
	public static final String DBUpdateFile_PATH = "/yaoxia/";
	public static final String DATABASE_NAME = "yaoxiadb.db";
	public static final String DATABASE_TEMP_FULLPATH = "/sdcard/yaoxia/yaoxia.db";
	public static final String UPDATE_FILE_NAME = "update.xml";
	public static final int DATABASE_VERSION = 1;
	public static final String DRUG_TABLE_NAME = "DrugData";
	public static final String DISEASE_TABLE_NAME = "DiseaseData";
	
	public static final String KEY_ID = "_id";
	public static final String COLUMN_Name = "name";
	public static final String COLUMN_QueryId = "queryid";
	
	public static final String DRUG_COLUMN_BrandName = "BrandName";
	public static final String DRUG_COLUMN_CommonName = "CommonName";
	
	
	public static final String QUERY_DRUG_SUGGEST = 
			"SELECT "+
				KEY_ID+" ,"+
				COLUMN_Name+" as suggest_text_1, "+
				DRUG_COLUMN_CommonName+" as suggest_text_2,"+
				KEY_ID+" as suggest_intent_data,"+
				"'_-1' as suggest_shortcut_id ,"+
				" 'android.resource://com.wxq.yaoxia/drawable/yx_drug_icon2' as suggest_icon_1 " +
			" FROM "+DRUG_TABLE_NAME+
			" WHERE "+COLUMN_Name+" like ?";
	public static final String QUERY_DISEASE_SUGGEST = 
			"SELECT "+
				KEY_ID+" ,"+
				COLUMN_Name+" as suggest_text_1, "+
				"'疾病'"+" as suggest_text_2,"+
				KEY_ID+" as suggest_intent_data,"+
				"'_-1' as suggest_shortcut_id ,"+
				" 'android.resource://com.wxq.yaoxia/drawable/yx_disease_icon2' as suggest_icon_1 " +
			" FROM "+DISEASE_TABLE_NAME+
			" WHERE "+COLUMN_Name+" like ?";
	//----------------药品搜索---------------------------
	public static final String QUERY_DRUGS_WITH_NAME = 
			"SELECT * "+
			"FROM "+DRUG_TABLE_NAME+
			" WHERE "+COLUMN_Name+" LIKE ?";
	
	public static final String QUERY_DRUG_WITH_ID =
			"SELECT * "+
			"FROM "+DRUG_TABLE_NAME+
			" WHERE "+KEY_ID+" = ?";
	
	public static final String QUERY_DRUG_WITH_QUERYID = 
			"SELECT * "+
			"FROM "+DRUG_TABLE_NAME+
			" WHERE "+COLUMN_QueryId+" = ?";
	
	public static final String QUERY_DRUG_COMMON_USE = 
			"select CommonDrug._id as _id,name,BrandName,CommonName,DrugData.queryid as queryid from CommonDrug,DrugData where CommonDrug.drugId = DrugData._id";
	
	//----------------疾病搜索---------------------------
	public static final String QUERY_DISEASE_WITH_NAME = 
			"SELECT * "+
			"FROM "+DISEASE_TABLE_NAME+
			" WHERE "+COLUMN_Name+" LIKE ?";
	
	public static final String QUERY_DISEASE_WITH_ID =
			"SELECT * "+
			"FROM "+DISEASE_TABLE_NAME+
			" WHERE "+KEY_ID+" = ?";
	
	public static final String QUERY_DISEASE_WITH_QUERYID = 
			"SELECT * "+
			"FROM "+DISEASE_TABLE_NAME+
			" WHERE "+COLUMN_QueryId+" = ?";
	
	public static final String QUERY_DISEASE_COMMON_USE = 
			"select _id,diseaseName as name,queryId as queryid from CommonDisease";
	
	//-----------------------全部搜索-------------------------
	public static final String QUERY_BOTH_SUGGEST = 
			"select * from "+
				"(   select " +
				         "_id," +
				         "name  as suggest_text_1," +
				         "'疾病'  as suggest_text_2," +
				         "'android.resource://com.wxq.yaoxia/drawable/yx_disease_icon2' as suggest_icon_1 ," +
				         "'"+YX_USE_DISEASE+"'"+" as suggest_intent_data, " +
				         "  _id as suggest_intent_extra_data,"+
				         "'_-1' as suggest_shortcut_id " +
				     "from DiseaseData " +
				     "where name like ? " +
				") "+
			"union all "+ 
			"select * from"+ 
				"(   select " +
						"_id," +
						"name  as suggest_text_1," +
						"CommonName  as suggest_text_2 ," +
						"'android.resource://com.wxq.yaoxia/drawable/yx_drug_icon2' as suggest_icon_1," +
						"'"+YX_USE_DRUG+"'"+" as suggest_intent_data, " +
						"  _id as suggest_intent_extra_data,"+
						"'_-1' as suggest_shortcut_id " +
					"from DrugData " +
					"where name like ? " +
				")";
	public static final String QUERY_BOTH_WITH_NAME = 
			"select * from "+
			"(select _id,name,queryid,'use4disease' as BrandName, 'use4disease' as CommonName from DiseaseData where name like ? )"+
			" union all "+
			"select * from "+
			"(select _id,name,queryid,BrandName,CommonName from DrugData where name like ?)";
	public static final String QUERY_BOTH_WITH_DISEASE_ID = 
			"select _id,name,queryid,'use4disease' as BrandName, 'use4disease' as CommonName from DiseaseData where _id = ?";
	
	public static final String URL_DETAIL =   "http://www.yaoxia.com/ajaxServlet?style=ae062a0f29297c33f8ab85b1d4b7741f&flag=%s&key=%s&timestamp=%s&checksum=%s";
	public static final String URL_REGISTER = "http://www.yaoxia.com/ajaxServlet?style=b20d020a02da7ab3feb835e0a6ef0dcd&emailaddr=%s&password1=%s&password2=%s&disname=%s&timestamp=%s&checksum=%s";
	public static final String URL_LOGIN =    "http://www.yaoxia.com/ajaxServlet?style=edf0dea5e5f48bfd5b3f92211ee537b3&username=%s&password=%s&timestamp=%s&checksum=%s"; 
	public static final String URL_UPDATE =   "http://www.yaoxia.com/ajaxServlet?style=8b833da7cd540170b8b513d84b0f2df1&timestamp=%s";
	
}
